package com.birdy.code;

/**
 * @author birdy
 * @date 2022/5/6 10:32 AM
 */
public enum CheckComment {
    S(1, "S"),
    A(2, "A"),
    B(3, "B"),
    C(4, "C"),
    D(5, "D");
    private int num;
    private String comment;

    private CheckComment(int num, String comment) {
        this.num = num;
        this.comment = comment;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @Override
    public String toString() {
        return "CheckComment{" +
                "num=" + num +
                ", comment='" + comment + '\'' +
                '}';
    }

    public static int getCommentByScore(int score) {
        if (score >= 100) {
            return S.getNum();
        } else if (score >= 80) {
            return A.getNum();
        } else if (score >= 60) {
            return B.getNum();
        } else if (score >= 40) {
            return C.getNum();
        } else {
            return D.getNum();
        }
    }

    public static int num(String comment) {
        switch (comment) {
            case "S":
                return S.getNum();
            case "A":
                return A.getNum();
            case "B":
                return B.getNum();
            case "C":
                return C.getNum();
            case "D":
                return D.getNum();
            default:
                return 0;
        }
    }
    public static String comment(int num) {
        switch (num) {
            case 1:
                return S.getComment();
            case 2:
                return A.getComment();
            case 3:
                return B.getComment();
            case 4:
                return C.getComment();
            case 5:
                return D.getComment();
            default:
                return "";
        }
    }
}
